<?php
/*
 * This is users page.
 */
include 'config.php';
include 'Com/user_operations.php';
$ussr = new Usr();
$user = true;
?>
<html>
    <head>
        <title>Users</title>
        <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
        <style media="all" type="text/css">@import "css/all.css";</style>
    </head>
    <body>
        <div id="main">
            <?php include 'nav.php'; ?>
            <div id="middle">
                <div id="left-column">
                    <h3>Users List</h3>
                    <ul class="nav">
                        <li><a href="users?pm=1">SalusMe</a></li>
                        <li><a href="users?pm=2">SalusBaby</a></li>
                        <li class="last" ><a href="users.php?p=new">Add New</a></li>
                    </ul>                    
                </div>

                <!--             Details starts-->
                <div id="center-column">

                    <?php
                    if ($_GET['pm'] != '') {
                        $pid = $_GET['pm'];
                        ?>
                        <div class="top-bar">
                            <h1>List Of
                                <?php
                                if ($pid == '1') {
                                    echo 'SalusMe';
                                }
                                if ($pid == '2') {
                                    echo 'SalusBaby';
                                }
                                ?>
                            </h1>
                            <div class="breadcrumbs"><a href="index">Homepage</a></div>
                        </div>
                        <br /><hr/>                         
                        <?php
                            $q1 = $ussr->get_buy_details($pid);                            
                            while ($r11 = mysql_fetch_array($q1)) {
                               $q2 = $ussr->get_user_by_subs($r11['id'],$r11['product_year']);
                            }
                        ?>
                        
                        
                        <br><hr><hr>                        
                        <?php
                    } elseif ($_GET['p'] == 'new') {
                        /*
                         * This is for creating new entry.
                         */
                        ?>


                        <div class="top-bar">
                            <h1>New User,</h1>
                            <div class="breadcrumbs"><a href="users">User List</a></div>
                        </div>
                        <br /><hr/> 
                        <h2>New Entry :</h2>
                        <?php
                    } elseif ($_GET['p'] == 'view') {
                        $id = $_GET['id'];
                        /*
                         * This is for viewing buyer data.
                         */
                        ?>
                        <div class="top-bar">
                            <h1>View Buyer Detail,</h1>
                            <div class="breadcrumbs"><a href="use">User List</a></div>                            
                        </div>
                        <br /><hr/>                        
                        <h2>Take Action :</h2>
                        <?php
                        $blk = mysql_query("select banned from fa_user where id=$id");
                        while ($row = mysql_fetch_array($blk)) {
                            if ($row['banned'] == true) {
                                echo 'UnBlock ---><a href=users?p=a&id=' . $id . '><img src="img/approve.jpg" title="UnBlock This User" /></a>';
                            } else {
                                echo 'Block This ---><a href=users?p=b&id=' . $id . '><img src="img/banned.jpg" title="Block This User" /></a>';
                            }
                        }
                        ?><hr>
                        <h2>view details :</h2>
                        <div class="table"  >
                            <img src="img/bg-th-left.gif" width="8" height="7" alt="" class="left" />
                            <img src="img/bg-th-right.gif" width="7" height="7" alt="" class="right" />
                            <table class="listing" cellpadding="0" cellspacing="0">
                                <?php
                                $getdetails0 = mysql_query("desc salus_user_profile_detail ");
                                $getdetails1 = mysql_query("select * from salus_user_profile_detail where FK_fa_user_id ='" . $_GET['id'] . "' ");
                                $i1 = 0;
//                        while ($row2 = mysql_fetch_array($getdetails0)) {
//                            //$dec[$i1]= $row2['']
//                            echo $row2[0];
//                        }
                                while ($row3 = mysql_fetch_array($getdetails1)) {
                                    ?>

                                    <tr><td>Name : </td><td><?= $row3[3] ?></td></tr>
                                    <tr><td>Surname : </td><td><?= $row3[4] ?></td></tr>
                                    <tr><td>Sex : </td><td><?= $row3[5] ?></td></tr>
                                    <tr><td>Birth Date : </td><td><?= $row3[6] ?></td></tr>
                                    <tr><td>Address : </td><td><?= $row3[8] ?></td></tr>
                                    <tr><td>Zip code : </td><td><?= $row3[9] ?></td></tr>
                                    <tr><td>City : </td><td><?= $row3[10] ?></td></tr>
                                    <tr><td>Country : </td><td><?= $row3[12] ?></td></tr>
                                    <tr><td>Phone : </td><td><?= $row3[13] ?></td></tr>
                                    <tr><td>Mobile : </td><td><?= $row3[14] ?></td></tr>
                                    <tr><td>Personal Identification Code : </td><td><?= $row3[15] ?></td></tr>
                                    <tr><td>National Health Service Personal Code  : </td><td><?= $row3[16] ?></td></tr>
                                    <tr><td>PIN Code : </td><td><?= $row3[17] ?></td></tr>
                                    <tr><td>Email : </td><td><?= $row3[18] ?></td></tr>
                                    <tr><td>Height : </td><td><?= $row3[20] ?> cm</td></tr>
                                    <tr><td>Weight : </td><td><?= $row3[21] ?> KG</td></tr>
                                    <tr><td>Blood Group : </td><td><?= $row3[22] ?></td></tr>
                                    <tr><td>Religion : </td><td><?= $row3[23] ?></td></tr>

                                </table>
                            </div><hr>


                            <?php
                        }
                    } elseif ($_GET['p'] == '') {
                        ?>
                        <div class="top-bar">
                            <h1> User Registry,</h1>                            
                        </div>
                        <br /><hr/> 
                        <h2>Info :</h2>
                        This page is for handling users by admin. Left side there are menus, from where you can take decisions on particular user.
                    <?php
                    } elseif ($_GET['p'] == 'b') {
                        /*
                         * Block user
                         */
                        $ussr->block_user($_GET['id']);
                    } elseif ($_GET['p'] == 'a') {
                        /*
                         * UnBlock user
                         */
                        $ussr->approve_user($_GET['id']);
                    }
                    ?>
                    <!--                   ends here-->
                </div>


                <div id="right-column">
                    <strong class="h">INFO</strong>
                    <div class="box">This is user's detail page. </div>
                    <div id="google_translate_element"></div>
                </div>
            </div>
            <div id="footer"></div>
        </div>


    </body>
</html>
